home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 049a / rm900806.zip / WDATIME.ASM < prev    next >
Assembly Source File  |  1988-05-22  |  5KB  |  116 lines

  1. ;------------------------------------------------------------------------------
  2. ; EQUATES
  3. ;------------------------------------------------------------------------------
  4. beep    equ     07h                     ; console BEEP
  5. lf      equ     0Ah                     ; linefeed
  6. cr      equ     0Dh                     ; carriage return
  7. eof     equ     1Ah                     ; End Of File marker
  8.  
  9.  
  10. ;------------------------------------------------------------------------------
  11. ; START OF CODE
  12. ;------------------------------------------------------------------------------
  13. code    segment
  14.         assume  cs:code, ds:code, es:code
  15.         org     100h
  16.  
  17. start:
  18.         jmp     getparms
  19.  
  20.         banner  db      'WhatDateTIME v1.0 of 05/22/88. By Jan R. Terpstra ->Militantly Public Domain!<-',cr,lf,'$',eof
  21.         help    db      'Helpfile WDATIME.HLP not found - Usage: WDATIME c',cr,lf,beep,'$'
  22.         file    db      'WDATIME.HLP',00h
  23.         buffer  db      64 dup(?)
  24.  
  25. getparms:
  26.         lea     dx,banner               ; point to string
  27.         mov     ah,09h                  ; print it
  28.         int     21h                     ; via DOS
  29.         mov     si,80H                  ; Address of PSP commandline
  30.         mov     ah,[si]                 ; Get input length
  31.         cmp     ah,0                    ; Any parms?
  32.         je      no_parms                ; No - show help
  33.         add     si,2                    ; Point to first parm
  34.         cmp     byte ptr [si],'t'       ; Check time?
  35.         je      get_time                ; yup
  36.         mov     ah,2Ah                  ; get the current time
  37.         int     21h                     ; via DOS
  38.         cmp     byte ptr [si],'d'       ; Check date?
  39.         jne     weekday                 ; yup
  40.         mov     al,dl                   ; day in AL
  41.         jmp     exit
  42.  
  43. weekday:
  44.         cmp     byte ptr [si],'w'       ; Check weekday?
  45.         jne     get_month               ; yup
  46.         inc     al                      ; weekday (1 = sun, 7 = sat) in AL
  47.         jmp     exit
  48.  
  49. get_month:
  50.         cmp     byte ptr [si],'m'       ; Check month?
  51.         jne     no_parms                ; something wrong here....
  52.         mov     al,dh                   ; month in AL
  53.         jmp     exit
  54.  
  55. get_time:
  56.         mov     ah,2ch                  ; get the current time
  57.         int     21h                     ; via int21
  58.         mov     al,ch                   ; move hours in AL
  59.         cbw                             ; convert to word
  60.         mov     bl,10                   ; setup for multiply
  61.         mul     bl                      ; multiply by 10
  62.         mov     dl,al                   ; store in DL
  63.         mov     al,cl                   ; minutes in AL
  64.         mov     bl,06h                  ; setup for divide
  65.         cbw                             ; convert to word
  66.         div     bl                      ; divide by 10
  67.         add     al,dl                   ; set errorlevel
  68.         jmp     exit                    ; and ready
  69.  
  70. no_parms:
  71.         lea     dx,file                 ; point to filename
  72.         mov     ax,3D00h                ; open file, compatability mode
  73.         int     21h                     ; via DOS
  74.         jc      no_help                 ; if not here, complain
  75.         mov     bx,ax                   ; filehandle in BX
  76.  
  77. read_file:
  78.         lea     dx,buffer               ; point to buffer
  79.         mov     ah,3Fh
  80.         mov     cx,64                   ; read 64 bytes
  81.         int     21h                     ; via DOS
  82.         push    ax                      ; save count
  83.         lea     si,buffer               ; point to buffer
  84.         mov     cx,ax                   ; # of chars to print
  85.  
  86. prt_loop:
  87.         mov     dl,[si]                 ; get a char
  88.         cmp     dl,eof                  ; end of file?
  89.         je      looper                  ; don't print
  90.         mov     ah,02h                  ; print it
  91.         int     21h                     ; via DOS
  92. looper:
  93.         inc     si                      ; point to next char
  94.         loop    prt_loop                ; more?
  95.         pop     cx                      ; get count back
  96.         cmp     cx,64                   ; 64 chars read?
  97.         je      read_file               ; yup, possibly more
  98.         mov     ah,3Eh                  ; close file
  99.         int     21h                     ; via DOS
  100.         jmp     done
  101.  
  102. no_help:
  103.         lea     dx,help                 ; point to string
  104.         mov     ah,09h                  ; print it
  105.         int     21h                     ; via DOS
  106.  
  107. done:
  108.         mov     al,0FFh                 ; errorlevel = 255
  109.  
  110. exit:
  111.         mov     ah,4Ch                  ; exit with errorlevel set
  112.         int     21h                     ; end
  113.  
  114. code    ends
  115. end     start
  116.